#!/usr/bin/env python3
# -*- coding:utf-8 -*-


# 简述面向对象中__new__和__init__区别
"""
class A(object):
    def __init__(self):
        print("这是init方法",self)

    def __new__(cls):
        print("这是cls的ID",id(cls))
        print("这是new方法",object.__new__(cls))
        return object.__new__(cls)

A()
print("这是类A的ID",id(A))
"""


# Python中生成随机整数,随机小数,0--1之间小数方法?
"""
'''
- 随机整数:`random.randint(a,b)`,生成区间内的整数.
- 随机小数: 用numpy库,利用np.random.randn(5)生成5个随机小数.
- 0-1随机小数: `random.random()`,括号中不传参.
'''
import random
import numpy as np 

result = random.randint(10,20)  # 区间
res = np.random.randn(5)
ret = random.random()  # 不能传数值.
print("正整数",result)
print("5个随机小数",res)
print("0-1随机小数",ret)
"""

"""
import re

str = '<div class="nam">中国</div>'
res = re.findall(r'<div class=".*">(.*?)</div>',str)
# .* 中的. 代表可有可无,*代表任意字符.满足类名可以变化. (.*?)提取文本.
print(res)
"""


# Python中断言方法举例 
a = 3
assert(a>1)
print("断言成功,程序继续向下执行")

b = 4
assert(b>7)
print("断言失败,程序报错")
'''
输出为:
断言成功,程序继续向下执行
Traceback (most recent call last):
  File "interview.py", line 51, in <module>
    assert(b>7)
AssertionError
'''

